<script lang="ts" setup>
import {DocumentEditor} from "@onlyoffice/document-editor-vue";

const config = ref({
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkb2N1bWVudFR5cGUiOiJjZWxsIiwiZG9jdW1lbnQiOnsiZmlsZVR5cGUiOiJ4bHN4Iiwia2V5IjoiYzE2ZmIwNWIyYWFhMDFjYzI3MWEiLCJ0aXRsZSI6InRlc3QueGxzeCIsInVybCI6Imh0dHA6Ly8xOTIuMTY4LjEuNzU6MTAwNjIvdXBsb2Fkcy9hM2QxYWJiOC05ZWZlLTljZDAtMzhhOC1hYTdjYThlMjZjZGIvMmQ4Y2JkNmUtZmY2Zi01ZmQ3LWQ1NTktMTVmODI1MzMyYTliLzIwMjMwNzI3LzlhMjJhMTRhLTg1ZWUtNGNkNy1iMWU3LWVjMmIzNThkMmYzNS54bHN4In0sImVkaXRvckNvbmZpZyI6eyJsYW5nIjoiemgiLCJjYWxsYmFja1VybCI6Imh0dHA6Ly8xOTIuMTY4LjEuMTAxOjEwMDYyL2FwaS9Pbmx5T2ZmaWNlTWFuYWdlci9TYXZlRG9jdW1lbnQ_dXJsPWh0dHA6Ly8xOTIuMTY4LjEuNzU6MTAwNjIvdXBsb2Fkcy9hM2QxYWJiOC05ZWZlLTljZDAtMzhhOC1hYTdjYThlMjZjZGIvMmQ4Y2JkNmUtZmY2Zi01ZmQ3LWQ1NTktMTVmODI1MzMyYTliLzIwMjMwNzI3LzlhMjJhMTRhLTg1ZWUtNGNkNy1iMWU3LWVjMmIzNThkMmYzNS54bHN4In19.L5dyP46xkpubYv0cMjUphjbsilx3FHhwUIjYVXHFNNM",
  "documentType": "cell",
  "document": {
    "fileType": "xlsx",
    "key": "c16fb05b2aaa01cc271a",
    "title": "test.xlsx",
    "url": "http://192.168.1.75:10062/uploads/a3d1abb8-9efe-9cd0-38a8-aa7ca8e26cdb/2d8cbd6e-ff6f-5fd7-d559-15f825332a9b/20230727/9a22a14a-85ee-4cd7-b1e7-ec2b358d2f35.xlsx"
  },
  "editorConfig": {
    "lang": "zh",
    "callbackUrl": "http://192.168.1.101:10062/api/OnlyOfficeManager/SaveDocument?url=http://192.168.1.75:10062/uploads/a3d1abb8-9efe-9cd0-38a8-aa7ca8e26cdb/2d8cbd6e-ff6f-5fd7-d559-15f825332a9b/20230727/9a22a14a-85ee-4cd7-b1e7-ec2b358d2f35.xlsx"
  }
})

const onDocumentReady = () => {
  console.log("Document is loaded");
}

const onLoadComponentError = (errorCode: number, errorDescription: string) => {
  switch (errorCode) {
    case -1: // Unknown error loading component
      console.log(errorDescription);
      break;

    case -2: // Error load DocsAPI from http://documentserver/
      console.log(errorDescription);
      break;

    case -3: // DocsAPI is not defined
      console.log(errorDescription);
      break;
  }
}


onMounted(() => {

})
</script>
<template>
	<!--documentServerUrl="http://192.168.1.65/"-->
	<!--documentServerUrl="https://onlyoffice.gudu.fun/"-->
	<!--documentServerUrl="https://documentserver/web-apps/apps/api/documents/api.js"-->
  <DocumentEditor
    id="docEditor"
    documentServerUrl="http://192.168.1.65/"
    :config="config"
    :events_onDocumentReady="onDocumentReady"
    :onLoadComponentError="onLoadComponentError"
  />
</template>
